<?php

use yii\grid\GridView;
use common\helpers\Html;
use common\helpers\Url;
use common\helpers\ImageHelper;
use common\models\bonus\Bonus;
use common\enums\BonusEnum;


$this->title = '分布奖';
$this->params['breadcrumbs'][] = ['label' => '汇总', 'url' => ['baobiao']];
$this->params['breadcrumbs'][] = ['label' => $this->title];

?>

<div class="row">
    <div class="col-xs-12">
        <div class="box">
             <div class="box-header">
                <h3 class="box-title"><?= $this->title; ?></h3>
                <div class="box-tools">

                </div>
            </div>
            <div class="box-body table-responsive">
                <?= GridView::widget([
                    'dataProvider' => $dataProvider,
                    // 'filterModel' => $searchModel,
                    //重新定义分页样式
                    'tableOptions' => ['class' => 'table table-hover rf-table'],
                    'columns' => [
                        [
                            'class' => 'yii\grid\SerialColumn',
                            'visible' => false, // 不显示#
                        ],
                        [
                            'attribute' => 'created_at',
                            'filter' => false, //不显示搜索框
                            'format' => ['date', 'php:Y-m-d'],
                        ],
                        [
                            'attribute' => 'sales',
                            'filter' => false, //不显示搜索框
                        ],
                        [
                            'attribute' => 'bonus',
                            // 'filter' => Bonus::$typeArr, //不显示搜索框
                            'filter' => false, //不显示搜索框

                        ],
                        [
                            'attribute' => 'tax',
                            'filter' => false, //不显示搜索框
                        ],
                        [
                            'attribute' => 'fee',
                            'filter' => false, //不显示搜索框
                        ],
                        [
                            'attribute' => 'bonus_real',
                            'filter' => false, //不显示搜索框
                        ],
                        [
                            'attribute' => 'payment_at',
                            'format' => ['date', 'php:Y-m-d H:i:s'],
                            'filter' => false, //不显示搜索框

                        ],
                        [
                            'attribute' => 'bonus_at',
                            'filter' => false, //不显示搜索框
                            'format' => ['date', 'php:Y-m-d H:i:s'],
                        ],
                        [
                            'attribute' => 'status',
                            'value' => function($model){
                                return BonusEnum::getMap()[$model->status];
                            },
                            'filter' => false, //不显示搜索框
                        ],
                        [
                            'header' => '详情列表',
                            'value'=>function($model){
                                return Html::linkButton(['bonus-member','id'=>$model->id,'type'=>Bonus::BONUS_TYPE_COLLISION], '查看列表');
                            },
                            'format' => 'raw'
                        ],
                        [
                            'value'=>function($model){
                                if ($model->status == BonusEnum::WAIT_CALC) {
                                    return Html::linkButton(['collision-calc', 'id'=>$model->id], '结算奖金', [
                                        'class'=>'btn btn-sm btn-danger',
                                        'onclick'=>'if(!confirm("是否结算当期奖金"))return false;'
                                    ]);
                                }
                                if ($model->status == BonusEnum::IS_CALC) {
                                    return Html::linkButton(['collision-fee-check', 'id'=>$model->id], '结算税费', [
                                        'class'=>'btn btn-sm btn-info',
                                        'data-toggle' => 'modal',
                                        'data-target' => '#ajaxModal',
                                    ]);
                                }
                                if ($model->status == BonusEnum::IS_FEE) {
                                    return Html::linkButton(['collision-payment', 'id'=>$model->id], '释放当期奖金', ['class'=>'btn btn-sm btn-success', 'onclick'=>'if(!confirm("是否释放当期奖金"))return false;']);
                                }
                                return '';
                            },
                            'format' => 'raw'
                        ],
                 
                    ],
                ]); ?>
            </div>
        </div>
    </div>